main(i,u,l,o,v,e)
{
	for(gets(&i);~scanf("%d",&i);)
	{
		u=i/10000;
		i-=u*10000;
		l=i/5000;
		i-=l*5000;
		o=i/1000;
		i-=o*1000;
		v=i/500;
		i-=v*500;
		e=i/100;

		printf("%d %d %d %d %d\n",u,l,o,v,e);
	}
}
